<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">
<style>
    .table-border tbody tr td{
        border-top: 1px solid black;
    }
</style>
<section class="content-header">
    <h1>合同台帐查询</h1>
</section>
<section class="content">
    <div class="box-header">
        <form id="queryForm" onsubmit="return false;">
            <div class="row">
                <div class="form-inline">
                    <div class="form-group" style="margin-right: 10px;">
                        <label>项目编号</label>
                        <input type="text" name="contName" class="form-control" placeholder="项目编号" >
                    </div>
                    <!--<div class="form-group" style="margin-right: 10px;">-->
                        <!--<label>买方合同编号</label>-->
                        <!--<input type="text" name="buyCode" class="form-control" placeholder="买方合同编号">-->
                    <!--</div>-->
                    <div class="form-group" style="margin-right: 10px;">
                        <label>卖方合同编号</label>
                        <input type="text" name="sellCode" class="form-control" placeholder="卖方合同编号">
                    </div>
                    <div class="form-group" style="margin-right: 10px;">
                        <label>买方</label>
                        <input type="text" name="totalMethod" class="form-control" placeholder="买方">
                    </div>

                    <div class="form-group" style="margin-right: 10px;">
                        <label>标的物</label>
                        <input type="text" class="form-control" name="contAddress" autocomplete="off" placeholder="标的物">
                    </div>

                    <div class="form-group" style="margin-right: 10px;">
                        <label>地区</label>
                        <input type="text" class="form-control" name="remark" autocomplete="off" placeholder="地区">
                    </div>

                    <div class="form-group" style="margin-right: 10px;margin-top: 5px;">
                        <label>应收金额</label>
                        <select class="form-control" name="comp">
                            <option value="0">全部</option>
                            <option value="1">有</option>
                            <option value="2">无</option>
                        </select>
                    </div>

                    <div class="form-group" style="margin-right: 10px;margin-top: 5px;">
                        <label>类别</label>
                        <select class="form-control" name="contType" >
                            <option value="">全部</option>
                            <option value="对外销售">对外销售</option>
                            <option value="对内销售">对内销售</option>
                            <option value="合作制造">合作制造</option>
                        </select>
                    </div>


                    <button type="button" class="btn btn-success" id="btn-search" style="margin-top: 5px;">
                        <!--<i class="fa fa-search"></i>-->
                        <span class="Bold">搜索</span>
                    </button>
                </div>
            </div>
        </form>
    </div>
    <div class="box-body">
        <table id="bootstrap-table"  class="table-border" style="table-layout: fixed;word-break:break-all; word-wrap:break-word;"></table>
    </div>
    </div>
</section>
<div th:include="include :: footer"></div>

<script th:inline="javascript">
    /** 加载用户表格 */
    table = js.table.init({
        url: ctx + "contractManage/selContractList",
        showColumns: true,
        showExport: true,
        pageSize:100,
        pagination : true,
        columns: [
            {
                title: "操作",
                width: '60',
                formatter: function (value, row, index) {
                    var actions = [];
                    // actions.push('<a class="btn btn-info btn-xs" href="'+ ctx + 'contractManage/showDetail?quoteId=' + row.fkId + '&conId=' + row.id + '"> 查看合同</a> ');
                    if(hasP('con:contract:view')) {
                        actions.push('<a class="btn btn-info btn-xs" target="_blank" href="' + ctx + 'contractManage/lookContract?quoteId=' + row.fkId + '&conId=' + row.id + '&parentId=0"> 查看</a> ');
                    }
                    return actions.join('');
                }
            },
            {
                title: '序号', field: 'id', width: '50',
                formatter: function (value, row, index, field) {
                    var pageSize = table.bootstrapTable('getOptions').pageSize;
                    var pageNumber = table.bootstrapTable('getOptions').pageNumber;
                    return pageSize * (pageNumber - 1) + index + 1;
                }
            },
            // {width:200,title: "项目编号", field: 'contName'},
            // {width:200,title: "类别", field: 'contType'},
            // {width:200,title: "合同状态", field: 'contWay'},
            // {width:200,title: "买方", field: 'totalMethod'},
            // {width:200,title: "买方合同编号", field: 'buyCode'},
            // {width:200,title: "卖方合同编号", field: 'sellCode'},
            // {width:200,title: "签订日期", field: 'contYear'},
            // {width:200,title: "标的物", field: 'contAddress'},
            // {width:200,title: "数量", field: 'cnt'},
            // {width:200,title: "存档编号", field: 'saveCode'},
            {width:100,title: "项目编号", field: 'contName'},
            {width:200,title: "业主方", field: 'contPartner',
                formatter: function (value, row, index) {
                    if(value=='' || value==null){
                        return "<span class=\"label  badge \">无业主</span>";
                    }else{
                        return "";
                    }
                }
            },
            {width:80,title: "类别", field: 'contType'},
            {width:80,title: "合同状态", field: 'contWay'},
            {width:200,title: "买方", field: 'totalMethod'},
            {width:240,title: "买方合同编号", field: 'buyCode'},
            {width:240,title: "卖方合同编号", field: 'sellCode'},
            {width:100,title: "签订日期", field: 'contYear'},
            {width:120,title: "标的物", field: 'contAddress'},
            {width:120,title: "地址", field: 'remark'},
            {width:60,title: "数量", field: 'cnt'},
            {width:100,title: "存档编号", field: 'saveCode'},
            {width:100,title: "合同金额</br>(元)", field: 'partMoney',
                formatter: function (value, row, index) {
                    if(hasP("con:account:money")){
                        return value;
                    }else{
                        return "***";
                    }
                }
            },
            {width:80,title: "付款比例", field: 'scale',
                formatter: function (value, row, index) {
                    if(value>0.0){
                        return "<span class=\"label  badge  label-success\">"+value+"%</span>";
                    }else{
                        return "";
                    }
                }
            },
            {width:100,title: "已收金额</br>(元)", field: 'rmiActualMoney',
                formatter: function (value, row, index) {
                    if(hasP("con:account:money")){
                        return value;
                    }else{
                        return "***";
                    }
                }},
            {width:100,title: "应收金额</br>(元)", field: 'rmiActualMoneyAll',
                formatter: function (value, row, index) {
                    if(hasP("con:account:money")){
                        return value;
                    }else{
                        return "***";
                    }
                }},
            {width:50,title: "是否</br>坏账", field: 'isbad',
                formatter: function (value, row, index) {
                    if(value==1){
                        return "<span class=\"label  badge  label-warning\">√</span>";
                    }else{
                        return "";
                    }
                }
            },
            {width:100,title: "开票金额</br>(元)", field: 'invAmount',
                formatter: function (value, row, index) {
                    if(hasP("con:account:money")){
                        return value;
                    }else{
                        return "***";
                    }
                }},
            {width:100,title: "业主方", field: 'contPartner'},
            {width:100,title: "总包合同</br>金额(元)", field: 'totalMoney',
                formatter: function (value, row, index) {
                    if(hasP("con:account:money")){
                        return value;
                    }else{
                        return "***";
                    }
                }},
            {width:100,title: "付款比例", field: 'scaleAll',
                formatter: function (value, row, index) {
                    if(value>0.0){
                        return "<span class=\"label  badge  label-success\">"+value+"%</span>";
                    }else{
                        return "";
                    }
                }
            },
            {width:100,title: "已付金额</br>(元)", field: 'rmiActualMoneyAll',
                formatter: function (value, row, index) {
                    if(hasP("con:account:money")){
                        return value;
                    }else{
                        return "***";
                    }
                }},
            {width:100,title: "合同登记人", field: 'createUser'}
        ]
    });

    /**
     * 表格搜索
     */
    $("#btn-search").click(function () {
        js.table.search(table);
    });
</script>